﻿using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZhuXingFamilys.AuditIndicators.utils
{
    public class ExportView
    {
        public static bool ExportDWG(Document document, Autodesk.Revit.DB.View view, string filePath)
        {
            //导出设置选项
            DWGExportOptions exportOptions = new DWGExportOptions();
            exportOptions.FileVersion = ACADVersion.R2007;

            // Export the active view
            ICollection<ElementId> views = new List<ElementId>();
            views.Add(view.Id);
            // The document has to be saved already, therefore it has a valid PathName.
            bool exported = document.Export(Path.GetDirectoryName(filePath),
                Path.GetFileNameWithoutExtension(filePath), views, exportOptions);

            return exported;
        }
    }
}
